function Board(ctx, w, h) {
    this.ctx = ctx; 
    this.w = w;
    this.h = h;

    this.speed = 2;
}

Board.prototype.init = function(x, y) {
    this.x = x;
    this.y = y;
    this.draw(); 
};

Board.prototype.draw = function() {
    this.ctx.fillStyle = "#1db2a4";
    this.ctx.fillRect(this.x, this.y, this.w, this.h);
};

Board.prototype.moveLeft = function() {
    if(this.x <= 0 ) {
        this.x = 0;
        return;
    }
    this.x -= this.speed;
};

Board.prototype.moveRight = function() {
    if(this.x >= 700 ) {
        this.x = 700;
        return;
    }
    this.x += this.speed;
};

Board.prototype.solveCollision = function(ball) {
    var r = ball.r;
    var bx = ball.x;
    var by = ball.y;

    if((bx >= this.x) && (bx <= this.x + this.w)) {
        if(this.y > by && this.y - by <= r) {
            ball.speedY = -ball.speedY;
        }   
    } else {
        var dist;
        if(bx < this.x) {
            dist = Math.sqrt(Math.pow((bx - this.x),2) + Math.pow((by - this.y),2));
        } else {
            dist = Math.sqrt(Math.pow((bx - this.x - this.w),2) + Math.pow((by - this.y),2));
        }

        if(dist <= r) {        
            ball.speedY = -ball.speedY;
            ball.speedX = -ball.speedX;

        }
    }

};